package controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import model.daos.PlayerDao;
import model.daos.TeamDao;
import views.windows.StatisticsPanel;

public class StatisticsController extends StatisticsPanel
{
	private static final long serialVersionUID = 1L;

	public StatisticsController()
	{
		super();
		addActions();
	}

	public void addActions()
	{
		getMostrarButton().addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0)
			{
				TeamDao teamDao = new TeamDao();
				PlayerDao playerDao = new PlayerDao();
				
				getMaGanadorTextField().setText(teamDao.mostWinner().getName());
				getMeGanadorTextField().setText(teamDao.mostLoser().getName());
				getMaHrTextField().setText(playerDao.playerMoreHrs().getName());
				getMeHrTextField().setText(playerDao.playerLessHrs().getName());
				getMaImpulsadorTextField().setText(playerDao.playerMoreRbis().getName());
				getMeImpulsadorTextField().setText(playerDao.playerLessRbis().getName());
			}
		});
		
		getLimpiarButton().addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e)
			{
				getMaGanadorTextField().setText("");
				getMeGanadorTextField().setText("");
				getMaHrTextField().setText("");
				getMeHrTextField().setText("");
				getMaImpulsadorTextField().setText("");
				getMeImpulsadorTextField().setText("");
			}
		});
	}
}
